from django.db import models

# Create your models here.
class Artista(models.Model):
    first_name = models.CharField(max_length=30, blank=True)
    last_name = models.CharField(max_length=40, blank=True)
    grupo = models.CharField(max_length=60)

    def __unicode__(self):
        return '%s  %s - %s' %  (self. first_name, self.last_name, self.grupo)

    
class Cd(models.Model):
    titulo_cd = models.CharField(max_length=80)
    autor = models.ForeignKey(Artista)
    anio = models.CharField(max_length=4, blank=True)
    tapa = models.FileField(upload_to='tapa/', blank=True)
    genero = models.CharField(max_length=80)
    
    def __unicode__(self):
        return '%s - %s' % (self.titulo_cd, self.autor)

class Canciones(models.Model):
    titulo = models.CharField(max_length=80)
    duracion = models.CharField(max_length=4, blank=True)
    autor = models.ManyToManyField(Artista)
    cds = models.ForeignKey(Cd)
    
    def __unicode__(self): # para que aparezcan los nombres de los titulos
        return  '%s - %s' % (self.titulo, self.cds)

